from django.contrib import admin

# Register your models here.
from django.contrib import admin
from app_models.models import BookInfo, HeroInfo

class HeroInfoTabularInline(admin.TabularInline):
    model = HeroInfo  # 要编辑的对象
    extra = 1  # 附加编辑的数量






class BookInfoAdmin(admin.ModelAdmin):
    # 配置列表显示字段
    list_display = ['id', 'btitle','total_heros', 'bpub_date', 'bcomment', 'is_delete']
    # 连接
    # list_display_links = ('btitle')
    # 每页显示多少内容
    list_per_page = 3
    #"操作选项"的位置
    actions_on_top = True
    actions_on_bottom = True
    #过滤器，只能接收字段，会将对应字段的值列出来，用于快速过滤
    list_filter = ['is_delete']
    #搜索框,对指定字段的值进行搜索，支持模糊查询
    search_fields = ['btitle']
    #编辑页显示字段内容
    # fields = ['total_heros', 'bpub_date', 'bcomment']
    # fieldsets = (
    #     ('基本', {'fields': ['btitle', 'bpub_date']}),
    #     ('高级', {
    #         'fields': ['bread', 'bcomment'],
    #         'classes': ('collapse',)  # 是否折叠显示
    #     })
    # )
    # inlines = [HeroInfoStackInline]
    inlines = [HeroInfoTabularInline]



admin.site.register(BookInfo, BookInfoAdmin)
admin.site.register(HeroInfo)
admin.site.site_header = '某某书城'
admin.site.site_title = '某某书城MIS'
admin.site.index_title = '欢迎使用某某书城MIS'
